package javazuoye.one;

import java.util.Arrays;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/06/27 08:22
 */
public class _3_2_6 {

    public static void main(String[] args) {
        int[] res = yuesefu(new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 2);
        System.out.println(Arrays.toString(res));
    }

    public static int[] yuesefu(int[] nums, int m) {
        int len = nums.length;
        int[] res = new int[nums.length];
        int index = -1;
        int num = 1;
        while (num < len + 1) {
            index += m;
            index %= len;
            while (nums[index] == -1) {
                index++;
                index = index % len;
            }
            res[index] = num++;
            nums[index] = -1;
        }
        return res;
    }
}
